<?php
require_once('imageoutput.php');

if (isset($_GET['debug']) || isset($_POST['debug'])) {
	if ($_FILES["image"]["error"] > 0)
    {
    	echo "Error: " . $_FILES["image"]["error"] . "<br />";
    }
	else
    {
    	echo "Upload: " . $_FILES["image"]["name"] . "<br />";
		echo "Type: " . $_FILES["image"]["type"] . "<br />";
		echo "Size: " . ($_FILES["image"]["size"] / 1024) . " Kb<br />";
		echo "Stored in: " . $_FILES["image"]["tmp_name"];
    }
	exit(0);
}

if (isset($_FILES["image"])) {
	if ($_FILES["image"]["error"] > 0) {
		imageoutput('error.jpg','jpg', $_POST['title'], $_POST['text']);
	} else {
		$ext = strtolower(end(explode(".", $_FILES["image"]["name"])));
		imageoutput($_FILES["image"]["tmp_name"], $ext, $_POST['title'], $_POST['text']);
	}
} else {
	imageoutput('default.jpg','jpg', $_POST['title'], $_POST['text']);
}
exit(0);
?>
